/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-07-10
 * Time: 17:33
 */
class MyCircularQueue {

    private int[] elme;
    private int head;
    private int last;

    public MyCircularQueue(int k) {
        this.elme = new int[k+1];
    }
    //插入元素
    public boolean enQueue(int value) {
        if (isFull()) {
            return false;
        }
        this.elme[last] = value;
        last = (last+1)%this.elme.length;
        return true;
    }
    //删除元素
    public boolean deQueue() {
        if (isEmpty()) {
            return false;
        }
        head = (head+1)%this.elme.length;
        return true;
    }
    //获取头元素
    public int Front() {
        if (isEmpty()) {
            return -1;
        }
        return this.elme[head];
    }
    //获取队尾元素
    public int Rear() {
        if (isEmpty()) {
            return -1;
        }
        if (last == 0) {
            return this.elme[this.elme.length-1];
        } else {
            return this.elme[last-1];
        }
    }
    //判断队列是否为空
    public boolean isEmpty() {
        return head == last;
    }
    //判断队列是否为满
    public boolean isFull() {
        return ((last+1)%this.elme.length == head);
    }
}